# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=ordered-set
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=3.1.1
pkgrel=1
pkgdesc='An OrderedSet is a mutable data structure that is a hybrid of a list and a set(mingw-w64)'
arch=('any')
url='https://github.com/LuminosoInsight/ordered-set'
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python2-pytest"
              "${MINGW_PACKAGE_PREFIX}-python3-pytest")
source=(#${_realname}-${pkgver}.tar.gz::"https://github.com/LuminosoInsight/ordered-set/archive/release/${pkgver}.tar.gz"
        https://files.pythonhosted.org/packages/a3/b7/d4d69641cbe707a45c23b190f2d717466ba5accc4c70b5f7a8a450387895/ordered-set-${pkgver}.tar.gz)
sha256sums=('a7bfa858748c73b096e43db14eb23e2bc714a503f990c89fac8fab9b0ee79724')

prepare() {
  [[ -d ${srcdir}/${_realname}-${pkgver} ]] && rm -rf ${srcdir}/${_realname}-${pkgver}
  tar -xzf ${srcdir}/${_realname}-${pkgver}.tar.gz -C ${srcdir} || true

  cd "${srcdir}"
  cp -r ${_realname}-${pkgver} python2-build
  cp -r ${_realname}-${pkgver} python3-build
}

package_python3-ordered-set() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd ${srcdir}/python3-build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1

  install -Dm644 MIT-LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-ordered-set() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd ${srcdir}/python2-build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1

  install -Dm644 MIT-LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-ordered-set() {
  package_python2-ordered-set
}

package_mingw-w64-i686-python3-ordered-set() {
  package_python3-ordered-set
}

package_mingw-w64-x86_64-python2-ordered-set() {
  package_python2-ordered-set
}

package_mingw-w64-x86_64-python3-ordered-set() {
  package_python3-ordered-set
}
